package com.example.healthcondition.services.impl;


import com.example.healthcondition.entity.HealthData;
import com.example.healthcondition.mapper.HealthDataMapper;
import com.example.healthcondition.services.HealthDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HealthDataServiceImpl implements HealthDataService {

    private final HealthDataMapper healthDataMapper;

    @Autowired
    public HealthDataServiceImpl(HealthDataMapper healthDataMapper) {
        this.healthDataMapper = healthDataMapper;
    }

    @Override
    public HealthData findLatestByUserId(Integer userId) {
        return healthDataMapper.findLatestByUserId(userId);
    }

    @Override
    public int insertHealthData(HealthData healthData) {
        return healthDataMapper.insertHealthData(healthData);
    }

    @Override
    public int updateHealthData(HealthData healthData) {
        return healthDataMapper.updateHealthData(healthData);
    }

    @Override
    public HealthData findById(Integer dataId) {
        return healthDataMapper.findById(dataId);
    }

    @Override
    public List<HealthData> findAllByUserId(Integer userId) {
        return healthDataMapper.findAllByUserId(userId);
    }
}